<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <link rel="SHORTCUT ICON" href="<?php echo base_url() ?>style/layout/favicon.ico" />
        <title>Selamat Datang Di Anugerah Group Management System | PT ASP - Sidoarjo, Jawa Timur, Indonesia</title>
        <meta name="description" content="Selamat Datang Di Anugerah Group Management System" />
        <meta name="keywords" content="adl, pt" />
        <meta name="author" content="Codrops" />
        <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>style/login-layout/css/style.css" />
        <!--[if lte IE 7]><style>.main{display:none;} .support-note .note-ie{display:block;}</style><![endif]-->
        <style>
            body {background: #e1c192 url(<?php echo base_url() ?>style/login-layout/images/wood_pattern.jpg);}
        </style>
    </head>
    <body>
        <?php
        $timestamp = date("Y-m-dHis");
        ?>
        <div class="container">
            <header>
                <?php if(preg_match("#logout#i", $this->input->server("REQUEST_URI"))): ?>
                    <h1><strong>Anda Telah Keluar Dari Anugerah Group Management System</strong></h1>
                <?php else: ?>
                    <h1><strong>Selamat Datang Di Anugerah Group Management System</strong></h1>
                <?php endif; ?>
                <h2>PT ASP - Sidoarjo, Jawa Timur, Indonesia</h2>                
                <div class="support-note">
                    <span class="note-ie">Maaf, pakailah browser yang lebih bagus atau updatelah browser anda.</span>
                </div>

            </header>

            <section class="main">
                <form class="form-2" action="" method="POST" autocomplete="off">
                    <?php if(isset($eSt) || isset($eM)): ?>
                    <div class="error-box">
                        <strong>Error :</strong>
                        <?php if (isset($eM)) echo strip_tags($eM) . " "; else echo ""; ?><br/>
                        <?php if (isset($eSt)) echo strip_tags($eSt); else echo ""; ?>
                    </div>
                    <?php endif; ?>
                    <h1><span class="log-in">Form Login</span></h1>
                    <p class="float">
                        <label for="login"><i class="icon-user"></i>Username</label>
                        <input type="text" name="username<?php echo "_".$timestamp ?>" id="username<?php echo "_".$timestamp ?>" placeholder="Username" autocomplete="off">
                    </p>
                    <p class="float">
                        <label for="password"><i class="icon-lock"></i>Password</label>
                        <input type="password" name="password<?php echo "_".$timestamp ?>" id="password<?php echo "_".$timestamp ?>" placeholder="Password" class="showpassword" autocomplete="off">
                    </p>
                    <p class="clearfix" style="padding-top:5px;padding-left:20px">
                        <img src="<?php echo base_url('/images/tcpdf_logo.png');?>" width='90' height='90'/>    
                        <input type="submit" name="submit" id="submit" value="Masuk" style="float:right" onclick="event.preventDefault(); do_post();">
                    </p>
                    
<!--                    <input type="hidden" name="v" value="1" />-->
                    <input type="hidden" name="pageredirection" id="pageredirection" value="<?php if (isset($pageredirection)) echo $pageredirection. " "; else echo ""; ?>" />
                    <input type="hidden" name="pageaddress" value="<?php if (isset($pageaddress)) echo $pageaddress. " "; else echo ""; ?>" />                    
                </form>​​                
             </section>            
        </div>
        
        <!-- jQuery if needed -->
         <script type="text/javascript" src="<?php echo base_url();?>style/component/jquery-1.7.2.min.js"></script>
        <script type="text/javascript">
            jQuery("#username_<?php echo $timestamp;?>").bind("keypress", {}, keypressInBox);
            jQuery("#password_<?php echo $timestamp;?>").bind("keypress", {}, keypressInBox);

    function keypressInBox(e) {
        var code = (e.keyCode ? e.keyCode : e.which);
        if (code == 13) { //Enter keycode                        
            e.preventDefault();
            do_post();
        }
    };
    
    function do_post(){
        var data = {username : jQuery("#username_<?php echo $timestamp;?>").val(),
                    password : jQuery("#password_<?php echo $timestamp;?>").val(),
                    pageredirection : jQuery("#pageredirection").val(),
                    from_post : 1};
                
       jQuery("#submit").css("background", "url('<?php echo base_url();?>style/login-layout/images/ajax-loader.gif') 100% center no-repeat");
        jQuery.ajax({
            type: "POST",
            url : "<?php echo site_url('admin/login?' . $_SERVER["QUERY_STRING"]) ?>",
            data: data,
            async: false,
            cache: false,
            crossDomain: true,
            success: function(msg){
                if(msg == '1'){
                    location.href = '<?php echo site_url('admin/login?' . $_SERVER["QUERY_STRING"]);?>';
                }
                else{
                    alert(msg);
                    location.reload(); 
                }
            },
            error: AjaxFailed
        });
    }
    
    function AjaxFailed(result) {
            alert(result.status + ' ' + result.statusText);
            location.reload();
        }
    
    function print_r(printthis, returnoutput) {
    var output = '';

    if($.isArray(printthis) || typeof(printthis) == 'object') {
        for(var i in printthis) {
            output += i + ' : ' + print_r(printthis[i], true) + '\n';
        }
    }else {
        output += printthis;
    }
    if(returnoutput && returnoutput == true) {
        return output;
    }else {
//        alert(output);
return output;
    }
}
            $(function() {

                jQuery('#showPassword').click(function() {
                    if (jQuery("#showPassword").is(":checked")) {
                        jQuery('.icon-lock').addClass('icon-unlock');
                        jQuery('.icon-unlock').removeClass('icon-lock');
                    } else {
                        jQuery('.icon-unlock').addClass('icon-lock');
                        jQuery('.icon-lock').removeClass('icon-unlock');
                    }
                });
                
                jQuery('#password').val("");
                jQuery('#username').val("");
            });
        </script>
    </body>
</html>